<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/FInclude/includeTaglibs.jsp"%>
<!DOCTYPE HTML>
<html lang="zh-CN">
<head>
	<c:import url="/FInclude/backEndCssJs.jsp" />
</head>
<body>
<button onclick="location.href='add';">添加</button>
<c:forEach var="b" items="${list}">
<div class="content" mod="${b.bannerId }">
图片:<input type="file" mod="${b.bannerId }" name="file"/><br>
<img src="${frontPath }${b.pic}" mod="${b.bannerId }"><br>
<input type="hidden" value="${b.pic }" mod="${b.bannerId }" name="pic">
<input type="submit" value="删除" del="${b.bannerId }">
<input type="submit" value="修改" mod="${b.bannerId }">
</div>
</c:forEach>
<script>
	$("input[type=file][mod]").change(function(){
		var id = $(this).attr("mod");
		$(this).uploadFile( "../../file/banner.json",{},function(data){
			$("div[mod=" + id + "] img").attr("src", $.frontPath + data.url);
			$("div[mod=" + id + "] input[name=pic]").val(data.url);
		});
	});
	
	$("input[type=submit][mod]").click(function(){
		var id = $(this).attr("mod");
		$("div[mod="+id+"]").postData(
				"modify.json",
				{bannerId:id},
				function(data){
				$("div[mod=" + id + "] img").attr($.frontPath + data.url);
				$.refresh(0);
		});
	});
	
	$("input[type=submit][del]").click(function(){
		var id = $(this).attr("del");
		$.box({message:"是否删除？",title:"删除",ok:function(){
			
			$.post(
					"del.json",
					{bannerId:id},
					function(data){
					$.box("删除成功",function(){
						$.refresh(0);
					});
					
			});
		}});
	});
</script>
</body>
</html>